
const HtmlWebpackPlugin = require('html-webpack-plugin')//生成html
const path = require('path')

const worboxWebpackPlugin = require("workbox-webpack-plugin");


module.exports = {
    entry: './src/js/index.js', //单入口
    output: {
        filename: 'js/index.[contenthash].js',//增加哈希值 解决服务器缓存问题
        path: path.resolve(__dirname, 'dist')
    },
    module: {

    },
    plugins: [
        new HtmlWebpackPlugin({
            template: "./src/index.html",
            minify: {
                collapseWhitespace: true,//移除空格
                removeComments: true//移除注释
            }
        }),
        new worboxWebpackPlugin.GenerateSW({
            clientsClaim: true,
            skipWaiting: true
        }),
    ],

    mode: 'production'//生成环境会自动压缩js代码
}